Ti.include('lib/oauth_adapter.js');

var SinaWeiboHelper = function(){
	
	//var oAuthAdapter = new OAuthAdapter(
		//'4050189186',
		//'54043f40d50d0ad7feebf3259707fbd6',
		//'HMAC-SHA1'
	//);
	
	var oAuthAdapter = new OAuthAdapter( 
		'5202eead5f00901a8daa7fa3c91ba626',
	    '2424068513',
	    'HMAC-SHA1'
	);

	oAuthAdapter.loadAccessToken('sina');

	if (oAuthAdapter.isAuthorized() == false)
	{
	    var receivePin = function() {
	      oAuthAdapter.getAccessToken('http://api.t.sina.com.cn/oauth/access_token');
	      oAuthAdapter.saveAccessToken('sina');
	    };
	    oAuthAdapter.showAuthorizeUI('http://api.t.sina.com.cn/oauth/authorize?' + oAuthAdapter.getRequestToken('http://api.t.sina.com.cn/oauth/request_token'), receivePin);
	    
	}
	/*
	this.send = function(content){
		oAuthAdapter.send('http://api.t.sina.com.cn/statuses/update.json', [['status', screen_name]],'新浪微博','发布成功','发布失败');
	}
	*/
	this.shareImage = function(content, image){
		oAuthAdapter.send('http://api.t.sina.com.cn/statuses/upload.json', [['status', content],['pic', image]],'大魔术师提醒','分享成功','分享失败');
	}
	this.share = function(id){
		oAuthAdapter.send('http://api.t.sina.com.cn/statuses/repost.json', [['id', id]],'大魔术师提醒','转发成功','转发失败');
	}
	this.follow = function(user_id){
		oAuthAdapter.send('http://api.t.sina.com.cn/friendships/create.json', [['user_id', user_id]],'大魔术师提醒','关注成功','关注失败');
	}
	
}